


import {getUserInfoApi} from '@/request/api'

export default {

  namespaced: true,

  state: {
    carTotal : 0,
    userInfo:{
       nickName: '游客',
       coin: 0,
      //图片路径抽取了之后当成模块来使用    
       headImg: require("../../assets/img/userImg.f8bbec5e.png")
    }
  },
  mutations: {
     changeUserInfo(state,payload){
         state.carTotal =payload.carTotal;
         state.userInfo = payload.userInfo;
     },
     initUserInfo(){
      state.carTotal = 0,
      state.userInfo ={
            nickName: '游客',
            coin: 0,
            //图片路径抽取了之后当成模块来使用    
            headImg: require("../../assets/img/userImg.f8bbec5e.png")
         }
     }
  },
  
  actions: { 
      async ayncChangeUserInfo({commit}){
           //let userRes = await getUserInfoApi();
          commit('changeUserInfo',{
              carTotal: 20,
              userInfo: {
                nickName:'胡天赐',
                 coin: 100,
              }
          });
      }
  }
}
